﻿using System;
using System.Collections.Generic;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Topo.BLL.Estate
{
    public class HousingKeyBLL
    {
                public static string p_housingKey_save(int ID, int housingId, string KeyNo, int borrowerDeptID, string borrowerDept, int borrowerID, string borrower, int receiverID, string receiver, string Operator)
        {
             string outmsg = "";
             int newid = 0;
             string datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             using (_Database db = new _Database("estate"))
             {
                 ZLDC.DAL.Estate.HousingKeyDAL.p_housingKey_save(ID, housingId, KeyNo, borrowerDeptID, borrowerDept, borrowerID, borrower, receiverID, receiver, Operator, datetime,datetime, out outmsg, out newid, db);
             }
             return outmsg;
        }
                public static string p_housingKey_list_table(int page, int pagesize, int housingid)
        {
            DataTable dt = null;
            int total = 0;                       int pageall = 0;                     using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.HousingKeyDAL.p_housingKey_list_table(page, pagesize, housingid, ref total, db);
            }

            pageall = _Utility.GetPageAll(pagesize, total);      
            _Json json = new _Json(dt, "yyyy-MM-dd HH:mm:ss");
            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";

        }
                   public static string SelectKeyNoByHId(string id) 
        {
            return ZLDC.DAL.Estate.HousingKeyDAL.SelectKeyNoByHId(id);
        }
        public static string p_housing_Key_Report_list_table(int page,int pagesize,string condition) 
        {
            DataTable dt = null;
            int total = 0;
            int pageall = 0;
            using (_Database db = new _Database("estate")) 
            {
                dt = ZLDC.DAL.Estate.HousingKeyDAL.p_housing_Key_Report_list_table(page,pagesize,condition,ref total,db);
            }
            pageall = _Utility.GetPageAll(pagesize, total);                  _Json json = new _Json(dt, 1);
            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";

        }
    }
}
